Sending Emails
As of 25.04, the rule framework also allows you to send emails from rules. This functionality can be used like any other function from the rule framework.
The interface for the rule is as follows:
def send_email(self,
to_emails: list[str] | str,
subject: str,
content: str,
bcc_emails: list[str] | str | None = None):
"""
Sends an email using the EmailService.
Args:
to_emails (list[str] | str): The recipient(s) email address(es).
subject (str): The subject of the email.
content (str): The content/body of the email.
bcc_emails (list[str] | str | None): The BCC recipient(s) email address(es).
"""
Make sure to ask the Energyworx support team to see if the EmailService is enabled for your environment. All emails will be sent from the notify@energyworx.org email address.
Example of use:
def send_email_response(self, to_emails: list[str], bcc_emails: list[str] | None = None):
R""" Send an automated email response.
Arguments:
to_emails: The email addresses of the recipients
bcc_emails: The email addresses of the BCC recipients
"""
content = """<h1>This is an automated response from the Energyworx platform.</h1>"""
self.send_email(
to_emails=to_emails,
subject="Automated Response",
content=content,
bcc_emails=bcc_emails,
)